(defpackage :navigation-examples
  (:use :cl)
  (:export :define-navigation-examples))

(in-package :navigation-examples)


(defun define-breadcrumbs-example ()
  (spinneret:with-html
    (:div (:h3 "Breadcrumbs")
          (:div (:h4 "Breadcrumbs default")
                (dui:breadcrumbs "breadcrumbs text-sm"
                                 (:ul (:li (html:a "#" "Home"))
                                      (:li (html:a "#" "Documents"))
                                      (:li "Add Document"))))
          (:div (:h4 "Breadcrumbs with max-width")
                (dui:breadcrumbs "breadcrumbs max-w-xs text-sm"
                                 (:ul (:li "Long text 1")
                                      (:li "Long text 2")
                                      (:li "Long text 3")
                                      (:li "Long text 4")
                                      (:li "Long text 5")))))
    ))

(defun define-bottom-navigation-example ()
  (spinneret:with-html
    (:div (:h3 "Bottom Navigation")
          (:div (:h4 "Bottom Navigation default")
                (:div :class "grid"
                      (:div :class "bg-base-300 rounded-b-box rounded-se-box relative overflow-x-auto"
                            (dui:bottom-navigation "btm-nav relative"
                                                   ((dui:button "active" "Home") ; remove "active" in real usage
                                                    (dui:button "" "Content")
                                                    (dui:button "" "Settings")))))))))

(defun define-link-example ()
  (spinneret:with-html
    (:div (:h3 "Link default")
          (:div (:h4 "Link default")
                (dui:link "link" "#" "I'm a simple link" :id "default-link"))
          (:div (:h4 "Primary color")
                (dui:link "link link-primary" "#" "I'm a simple link with primary color")))))

(defun define-menu-example ()
  (spinneret:with-html
    (:div (:h3 "Menu default")
          (:div (:h4 "Menu default")
                (dui:menu "menu bg-base-200 rounded-box w-56"
                          ((:li (:a "Item 1"))
                           (:li (:a "Item 2"))
                           (:li (:a "Item 3")))))
          (:div (:h4 "Responsive: vertical on small screen, horizontal on large screen")
                (dui:menu "menu menu-vertical lg:menu-horizontal bg-base-200 rounded-box"
                          ((:li (:a "Item 1"))
                           (:li (:a "Item 2"))
                           (:li (:a "Item 3")))))
          (:div (:h4 "Menu with icon only")
                (dui:menu "menu bg-base-200 rounded-box w-32"
                          ((:li (dui:button "" (icons:home)))
                           (:li (dui:button "" (icons:info)))
                           (:li (dui:button "" (icons:sig))))))
          (:div (:h4 "Menu with icon only")
                (dui:menu "menu bg-base-200 rounded-box w-32"
                          ((:li (dui:button "" (icons:home)))
                           (:li (dui:button "" (icons:info)))
                           (:li (dui:button "" (icons:sig))))))
          (:div (:h4 " Menu with icon only with tooltip")
                (dui:menu "menu bg-base-200 rounded-box w-32"
                          ((:li (dui:tooltip "tooltip tooltip-right" "Home"
                                             (icons:home)))
                           (:li (dui:tooltip "tooltip tooltip-right" "Details"
                                             (icons:info)))
                           (:li (dui:tooltip "tooltip tooltip-right" "Stats"
                                             (icons:sig) "")))))
          )))

(defun define-navbar-example ()
  (spinneret:with-html
    (:div (:h3 "Navbar")
          (:div (:h4 "Navbar with title only")
                (dui:navbar "navbar bg-base-100"
                            ((html:a "#" "daisyUI" :class "btn btn-ghost text-xl"))))
          (:div (:h4 "Navbar with title and icon")
                (dui:navbar "navbar bg-base-100"
                            ((:div :class "flex-1"
                                   (html:a "#" "daisyUI" :class "btn btn-ghost text-xl"))
                             (:div :class "flex-none"
                                   (dui:button "btn btn-square btn-ghost" (icons:dots))))))
          )))

(defun define-tab-example ()
  (spinneret:with-html
    (:div (:h3 "Tab")
          (:div (:h4 "Tabs")
                (dui:tab "tabs"
                         ((html:a "#" "Tab 1" :class "tab")
                          (html:a "#" "Tab 2" :class "tab tab-active")
                          (html:a "#" "Tab 3" :class "tab"))))
          (:div (:h4 "Bordered")
                (dui:tab "tabs tabs-bordered"
                         ((html:a "#" "Tab 1" :class "tab")
                          (html:a "#" "Tab 2" :class "tab tab-active")
                          (html:a "#" "Tab 3" :class "tab"))))
          (:div (:h4 "Lifted")
                (dui:tab "tabs tabs-lifted"
                         ((html:a "#" "Tab 1" :class "tab")
                          (html:a "#" "Tab 2" :class "tab tab-active")
                          (html:a "#" "Tab 3" :class "tab"))))
          (:div (:h4 "radio tab lifted + tab content")
                (dui:tab "tabs tabs-lifted"
                         ((:input :type "radio" :name "my_tabs_2" :role "tab" :class "tab" :aria-label "Tab 1")
                          (:div :role "tabpanel" :class "tab-content bg-base-100 border-base-300 rounded-box p-6" "Tab content 1")
                          (:input :type "radio" :name "my_tabs_2" :role "tab" :class "tab" :aria-label "Tab 2" :checked "checked")
                          (:div :role "tabpanel" :class "tab-content bg-base-100 border-base-300 rounded-box p-6" "Tab content 2")
                          (:input :type "radio" :name "my_tabs_2" :role "tab" :class "tab" :aria-label "Tab 3")
                          (:div :role "tabpanel" :class "tab-content bg-base-100 border-base-300 rounded-box p-6" "Tab content 3"))))
          )))


(defun define-navigation-examples ()
  (spinneret:with-html
    (:div
     (define-breadcrumbs-example)
     (define-bottom-navigation-example)
     (define-link-example)
     ;; ...
     )))

(defun compile-breadcrumbs-example ()
  (spinneret:with-html-string
    (define-breadcrumbs-example)))

(defun compile-bottom-navigation-example ()
  (spinneret:with-html-string
    (define-bottom-navigation-example)))

(defun compile-link-example ()
  (spinneret:with-html-string
    (define-link-example)))

(defun compile-menu-example ()
  (spinneret:with-html-string
    (define-menu-example)))

(defun compile-navbar-example ()
  (spinneret:with-html-string
    (define-navbar-example)))

(defun compile-tab-example ()
  (spinneret:with-html-string
    (define-tab-example)))

(easy-routes:defroute navigation-breadcrumbs ("/navigation/breadcrumbs" :method :get) ()
  (compile-breadcrumbs-example))

(easy-routes:defroute navigation-bottom-navigation ("/navigation/bottom-navigation" :method :get) ()
  (compile-bottom-navigation-example))

(easy-routes:defroute navigation-link ("/navigation/link" :method :get) ()
  (compile-link-example))

(easy-routes:defroute navigation-menu ("/navigation/menu" :method :get) ()
  (compile-menu-example))

(easy-routes:defroute navigation-navbar ("/navigation/navbar" :method :get) ()
  (compile-navbar-example))

(easy-routes:defroute navigation-tab ("/navigation/tab" :method :get) ()
  (compile-tab-example))

(easy-routes:defroute navigation-test ("/navigation/test" :method :get) ()
  (spinneret:with-html-string
    ;;(icons:info)
    (dui:menu "menu bg-base-200 rounded-box"
              ((:li  (:svg
                      :class "h-5 w-5"
                      :fill "none"
                      :viewBox "0 0 24 24"
                      :stroke "currentColor"
                      (:path
                       :style "stroke-linecap: round; stroke-linejoin: round; stroke-width: 2"
                       :d "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z")))
               (:li (icons:home))
               (:li (icons:info))
               (:li (icons:sig))
               ;;(:li (dui:button "" (icons:info)))
               #+:ignore(:li (:button "" (icons:sig)))))
    ))
